package answer_factory;

import answers.IAnswer;
import answers.TrueFalseAnswer;

public class TrueFalseAnswerFactory implements IAnswerFactory
{
	@Override
	public IAnswer createAnswer(String encoding)
	{
		try
		{
			String [] tokens = encoding.split("\\s");
			int value = Integer.parseInt(tokens[2]);
			
			if(value ==0 || value ==1)
			{
				return new TrueFalseAnswer(value == 1);
			}
			else
			{
				return null;
			}
		}
		catch(NumberFormatException e)
		{
			return null;
		}
	}

}
